package Leetcode;

public class Leetcode_271 {
    public static int minElements(int[] nums, int limit, int goal) {
        long sum = 0;
        for (int x : nums) {
            sum += x;
        }
        long diff = Math.abs(sum - goal);
        return (int) ((diff + limit - 1) / limit);
    }

    public static void main(String[] args) {
        int[] nums = {1,-1,1};
        int limit = 3, goal = -4;
        System.out.println(minElements(nums,limit,goal));
    }
}
